package com.ruoyi.contract.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.contract.domain.InvoiceInformation;
import com.ruoyi.contract.service.IInvoiceInformationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 发票信息Controller
 * 
 * @author ruoyi
 * @date 2024-10-18
 */
@RestController
@RequestMapping("/contract/InvoiceInformation")
public class InvoiceInformationController extends BaseController
{
    @Autowired
    private IInvoiceInformationService invoiceInformationService;

    /**
     * 查询发票信息列表
     */
    @PreAuthorize("@ss.hasPermi('contract:InvoiceInformation:list')")
    @GetMapping("/list")
    public TableDataInfo list(InvoiceInformation invoiceInformation)
    {
        startPage();
        List<InvoiceInformation> list = invoiceInformationService.selectInvoiceInformationList(invoiceInformation);
        return getDataTable(list);
    }

    /**
     * 导出发票信息列表
     */
    @PreAuthorize("@ss.hasPermi('contract:InvoiceInformation:export')")
    @Log(title = "发票信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InvoiceInformation invoiceInformation)
    {
        List<InvoiceInformation> list = invoiceInformationService.selectInvoiceInformationList(invoiceInformation);
        ExcelUtil<InvoiceInformation> util = new ExcelUtil<InvoiceInformation>(InvoiceInformation.class);
        util.exportExcel(response, list, "发票信息数据");
    }

    /**
     * 获取发票信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('contract:InvoiceInformation:query')")
    @GetMapping(value = "/{invoiceInformationId}")
    public AjaxResult getInfo(@PathVariable("invoiceInformationId") Long invoiceInformationId)
    {
        return success(invoiceInformationService.selectInvoiceInformationByInvoiceInformationId(invoiceInformationId));
    }

    /**
     * 新增发票信息
     */
    @PreAuthorize("@ss.hasPermi('contract:InvoiceInformation:add')")
    @Log(title = "发票信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvoiceInformation invoiceInformation)
    {
        return invoiceInformationService.insertInvoiceInformation(invoiceInformation);
    }

    /**
     * 修改发票信息
     */
    @PreAuthorize("@ss.hasPermi('contract:InvoiceInformation:edit')")
    @Log(title = "发票信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InvoiceInformation invoiceInformation)
    {
        return toAjax(invoiceInformationService.updateInvoiceInformation(invoiceInformation));
    }

    /**
     * 删除发票信息
     */
    @PreAuthorize("@ss.hasPermi('contract:InvoiceInformation:remove')")
    @Log(title = "发票信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{invoiceInformationIds}")
    public AjaxResult remove(@PathVariable Long[] invoiceInformationIds)
    {
        return toAjax(invoiceInformationService.deleteInvoiceInformationByInvoiceInformationIds(invoiceInformationIds));
    }
}
